#include "preorderTraversal.h"
void preorderTraversal(TreeNode* root, vector<int>& cache)
{
    if (!root)
        return;
    else
    {
        cache.push_back(root->val);
        if (root->left)
            preorderTraversal(root->left, cache);
        if (root->right)
            preorderTraversal(root->right, cache);
    }
}
vector<int> preorderTraversal(TreeNode* root)
{
    vector<int> res;
    preorderTraversal(root, res);
    return res;
}